package com.maixy.dailydemo.thread;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ThreadController
 * @Description TODO
 * @Date 2022/1/19 15:19
 * @Author NINGMEI
 */
@RestController
@RequestMapping("/thread")
@Slf4j
public class ThreadController {

    @GetMapping("test1/{id}")
    public String test1(@PathVariable("id") Integer id) throws InterruptedException {
        log.info("进入方法，id:{}",id);
        synchronized(this) {
            Thread.sleep(5000);
            log.info("同步锁，id:{}",id);
        }
        return "ok";
    }
}
